Skip to content

Conversation

dzbarsky
Copy link

No description provided.

func (gen *Generator) Base64DataURL() string {
const prefix = "data:application/json;base64,"
data := gen.bytes()
buf := make([]byte, len(prefix)+base64.StdEncoding.EncodedLen(len(data)))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can also be done via strings.Builder with Grow and Write if preferred, it's essentially the same unsafe.String trick under the hood

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, avoiding unsafe is preferred.

@dzbarsky
Copy link
Author

@microsoft-github-policy-service agre

@dzbarsky
Copy link
Author

@microsoft-github-policy-service agree

@@ -1,11 +1,13 @@
package sourcemap

import (
"encoding/base64"
"encoding/json"
Copy link
Member

@jakebailey jakebailey Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure why you swapped out the json import? (Must have been auto import's fault)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants